//
//  bianjihysViewController.m
//  gangquOASystem
//
//  Created by michael on 2018/8/21.
//  Copyright © 2018年 czd. All rights reserved.
//

#import "bianjihysViewController.h"
#import "GDataDefines.h"
#import "OADepartmentModel.h"
#import "OAAttachmentsModel.h"
#import "OADetailDispatchModel.h"
#import "huiyishiViewController.h"
@interface bianjihysViewController ()
@property(nonatomic,strong)OADetailDispatchModel * detailPatchModel ;

@end

@implementation bianjihysViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

    // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制

    [formatter setDateFormat:@"YYYY-MM-dd"];

    //现在时间,你可以输出来看下是什么格式

    NSDate *datenow = [NSDate date];

    //----------将nsdate按formatter格式转成nsstring

   _time = [formatter stringFromDate:datenow];
     NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"LZPickerView" owner:nil options:nil];
    self.lzPickerVIew  = views[0];
    self.view.backgroundColor = [UIColor whiteColor];
            [self loaddata];
 UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"保存"style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonAction)];
// self.navigationItem.rightBarButtonItem = item1;
 [self loadData];

    // Do any additional setup after loading the view.
}
-(void)loadData{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];

    _array = @[@{@"unId":self.fieid},@{@"userId":userId}];
  
    [HttpTools postWithURL:@"exchassistant" arrays:_array method:@"contentMeetroom" success:^(id JSON) {
    
   NSLog(@"====%@",JSON);
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
//        ||[self.type isEqualToString:@"shouwen"]||[self.type isEqualToString:@"shiwei"]

    self.detailPatchModel = [self getDetailModel3:JSON];
    self.dic = [NSMutableDictionary dictionary];
for (NSString * allString in self.detailPatchModel.formArray) {
        NSArray * tempArray = [allString componentsSeparatedByString:@"##"];
        if (tempArray.lastObject) {
    [self.dic setObject:tempArray.lastObject forKey:tempArray.firstObject];

}

}
NSLog(@"%@",_dic);
NSLog(@"%@",_dic[@"会议名称"]);
self.name =self.dic[@"会议名称"];
self.bumen =self.dic[@"使用部门"];
self.time =self.dic[@"时间"];
self.leader =self.dic[@"参会领导"];
self.num =self.dic[@"会议人数"];
self.phone =self.dic[@"联系电话"];
self.placestring =self.dic[@"地点"];
self.mark =self.dic[@"需提供服务"];

//地点 = 10楼贵宾室;
//    会议人数 = ;
//    备注 = ;
//    需提供服务 = ;
//    参会领导 = ;
//    会议名称 = iso;
//    联系电话 = ;
//    登  记  人 = 沈善珍(shensz);
//    使用部门 = 党政办公室;
//    时间 = 2018-08-23下午到;
//    参会人数 = ;
        [self.tableView reloadData];
 
    } failure:^(NSError *error) {
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    }];
    
}
-(OADetailDispatchModel *)getDetailModel3:(NSString*)dataString;
{
    NSData * data = [dataString dataUsingEncoding:NSUTF8StringEncoding];
    OADetailDispatchModel * detailModel = [[OADetailDispatchModel alloc]init];
    GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData: data options:0 error:nil];
    //获取根节点（Users）
    GDataXMLElement *rootElement = [doc rootElement];
    //获取根节点下的节点（User）
    NSArray *rootData= [rootElement elementsForName:@"数据"];
    for (GDataXMLElement *data in rootData) {
      
            GDataXMLElement *documentElement= [[data elementsForName:@"文档"] objectAtIndex:0];
            detailModel.document = [documentElement stringValue];
        
        
        
            GDataXMLElement *filestep= [[data elementsForName:@"填写意见环节"] objectAtIndex:0];
            detailModel.flow = [filestep stringValue];
        
            GDataXMLElement *fileId= [[data elementsForName:@"唯一标识"] objectAtIndex:0];
            detailModel.fileId = [fileId stringValue];
        
        
    }
   
    
    
    
    return detailModel;
    
}
- (void)tyaction{
NSString *huiyi = [_huiyifield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *bumen = [_bumenfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *leader = [_leaderfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([huiyi isEqualToString:@""]|| huiyi.length == 0) {
     [self.view makeToast:@"会议名称为空!"];
}
else if ([_starttime isEqualToString:@""]|| _starttime.length == 0) {
     [self.view makeToast:@"开始时间为空!"];
}else if ([_endtime isEqualToString:@""]|| _endtime.length == 0) {
     [self.view makeToast:@"结束时间为空!"];
}else if ([bumen isEqualToString:@""]|| bumen.length == 0) {
     [self.view makeToast:@"使用部门为空!"];
}else if ([leader isEqualToString:@""]|| leader.length == 0) {
     [self.view makeToast:@"参会领导为空!"];
}else if ([_placestring isEqualToString:@""]|| _placestring.length == 0) {
     [self.view makeToast:@"地点为空!"];
}else{
NSString *json =[NSString stringWithFormat: @"{'unid':'%@','name':'%@','date':'%@','startTime':'%@','endTime':'%@','department':'%@','leader':'%@','personNum':'%@','tel':'%@','address':'%@','remark':'%@'}",_fieid,huiyi,_time,_starttime,_endtime,bumen,leader,_meetingnumfield.text,_phonefield.text,_placestring,_marktview.text];
NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];

    NSArray * array =@[@{@"json":json},@{@"sName":userId}];
[HttpTools postWithURL:@"exchassistant" arrays:array method:@"agreeMeetroom"  success:^(id JSON) {
 GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData: [JSON dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
        GDataXMLElement *rootElement = [doc rootElement];
        NSArray *arrData= [rootElement elementsForName:@"info"];
        NSString * message= nil;
        for (GDataXMLElement * subXMLElement in arrData) {
            GDataXMLElement * element = [[subXMLElement elementsForName:@"msg"] objectAtIndex:0];
            message  = [element stringValue];
        }
        if ([message isEqualToString:@"20"]) {
            [self.view.window makeToast:@"保存成功"];
[self performSelector: @selector(popaction) withObject: nil afterDelay:1.0f];

}else{
        [self.view.window makeToast:@"保存失败"];

}
 } failure:^(NSError *error) {
        [self.view.window makeToast:@"保存失败"];
    }];

}

}
- (void)btyaction{
NSString *huiyi = [_huiyifield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *bumen = [_bumenfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *leader = [_leaderfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([huiyi isEqualToString:@""]|| huiyi.length == 0) {
     [self.view makeToast:@"会议名称为空!"];
}
else if ([_starttime isEqualToString:@""]|| _starttime.length == 0) {
     [self.view makeToast:@"开始时间为空!"];
}else if ([_endtime isEqualToString:@""]|| _endtime.length == 0) {
     [self.view makeToast:@"结束时间为空!"];
}else if ([bumen isEqualToString:@""]|| bumen.length == 0) {
     [self.view makeToast:@"使用部门为空!"];
}else if ([leader isEqualToString:@""]|| leader.length == 0) {
     [self.view makeToast:@"参会领导为空!"];
}else if ([_placestring isEqualToString:@""]|| _placestring.length == 0) {
     [self.view makeToast:@"地点为空!"];
}else{
NSString *json =[NSString stringWithFormat: @"{'unid':'%@','name':'%@','date':'%@','startTime':'%@','endTime':'%@','department':'%@','leader':'%@','personNum':'%@','tel':'%@','address':'%@','remark':'%@'}",_fieid,huiyi,_time,_starttime,_endtime,bumen,leader,_meetingnumfield.text,_phonefield.text,_placestring,_marktview.text];
NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];

    NSArray * array =@[@{@"json":json},@{@"sName":userId}];
[HttpTools postWithURL:@"exchassistant" arrays:array method:@"disagreeMeetroom"  success:^(id JSON) {
 GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData: [JSON dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
        GDataXMLElement *rootElement = [doc rootElement];
        NSArray *arrData= [rootElement elementsForName:@"info"];
        NSString * message= nil;
        for (GDataXMLElement * subXMLElement in arrData) {
            GDataXMLElement * element = [[subXMLElement elementsForName:@"msg"] objectAtIndex:0];
            message  = [element stringValue];
        }
        if ([message isEqualToString:@"20"]) {
            [self.view.window makeToast:@"保存成功"];
[self performSelector: @selector(popaction) withObject: nil afterDelay:1.0f];

}else{
        [self.view.window makeToast:@"保存失败"];

}
 } failure:^(NSError *error) {
        [self.view.window makeToast:@"保存失败"];
    }];

}

}
- (void)popaction{
//    [defaults removeObjectForKey:@"dic"];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshData" object:nil]; //刷新发件箱，收件箱 数据
  for (UIViewController * VC in self.navigationController.viewControllers) {
        if ([VC isKindOfClass:[huiyishiViewController class]]) {
            [self.navigationController popToViewController:VC animated:YES];
                     break;
                     }

            }

}
- (void)loaddata{
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSArray * array = @[@{@"userId":userId}];
[HttpTools requestWithURL:@"exchassistant" arrays:array method:@"getMeetroom" success:^(id JSON) {
NSLog(@"%@",JSON);
NSArray *array0 = JSON[@"data"];
NSMutableArray *muarray = [NSMutableArray array];
for (NSDictionary *dic in array0) {
    [muarray addObject:dic[@"gwFstword"]];
}
_array = muarray;
[self initview];
} failure:^(NSError *error) {
    
    
    }];




}
- (void)initview{
if(!_tableView){
 _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,KScreenHeight-kTopHeight) style:UITableViewStylePlain];
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.bounces = NO;
_tableView.dataSource = self;
_tableView.delegate = self;
[self.view addSubview:_tableView];
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 9;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row ==1) {
    return 20+80+5;
}if (indexPath.row ==7) {
    return 100;
}else{
    return 60;


}

}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

if (indexPath.row ==0){
 static NSString *cellid00 = @"cellid00";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid00];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid00];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"会议名称";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _huiyifield = [[zhucetextfield alloc]init];
              _huiyifield.delegate = self;
    _huiyifield.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 40);
 
          [cell.contentView addSubview:_huiyifield];

}
  if(_dic&&![_name isEqual:[NSNull null]]){

 _huiyifield.text =_name;


 }
return cell;
}else if (indexPath.row ==1){
 static NSString *cellid01 = @"cellid01";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid01];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid01];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"时间";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
    _timebutton = [zhucebutton buttonWithType:UIButtonTypeCustom];
      _timebutton.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 40);
[_timebutton addTarget:self action:@selector(timeaction) forControlEvents:UIControlEventTouchUpInside];
   [cell.contentView addSubview:_timebutton];
     _starttimebutton = [zhucebutton buttonWithType:UIButtonTypeCustom];
      _starttimebutton.frame = CGRectMake(10, _timebutton.bottom+5, (KScreenWidth-20-50)/2, 40);
[_starttimebutton addTarget:self action:@selector(startaction) forControlEvents:UIControlEventTouchUpInside];
   [cell.contentView addSubview:_starttimebutton];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(_starttimebutton.right, _timebutton.bottom,50, 40)];
  label2.textColor = [UIColor colorWithHexString:@"484848"];
label2.text = @"到";
label2.textAlignment = 1;
    label2.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label2];
     _endtimebutton = [zhucebutton buttonWithType:UIButtonTypeCustom];
      _endtimebutton.frame = CGRectMake(label2.right, _timebutton.bottom+5, (KScreenWidth-20-50)/2, 40);
[_endtimebutton addTarget:self action:@selector(endaction) forControlEvents:UIControlEventTouchUpInside];
   [cell.contentView addSubview:_endtimebutton];
    [_starttimebutton setTitle:@"开始时间" forState:UIControlStateNormal];
         [_endtimebutton setTitle:@"结束时间" forState:UIControlStateNormal];

}
  if(_starttime.length>0){
         [_starttimebutton setTitle:_starttime forState:UIControlStateNormal];
         }
           if(_endtime.length>0){
         [_endtimebutton setTitle:_endtime forState:UIControlStateNormal];
}
         [_timebutton setTitle:_time forState:UIControlStateNormal];

return cell;
}else if (indexPath.row ==2){
 static NSString *cellid02 = @"cellid02";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid02];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid02];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"使用部门";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _bumenfield = [[zhucetextfield alloc]init];
              _bumenfield.delegate = self;
    _bumenfield.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 40);
 
          [cell.contentView addSubview:_bumenfield];

}
    if(_dic&&![_bumen isEqual:[NSNull null]]){

 _bumenfield.text =_bumen;


 }
return cell;
}else if (indexPath.row ==3){
 static NSString *cellid03 = @"cellid03";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid03];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid03];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"参会领导";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _leaderfield = [[zhucetextfield alloc]init];
              _leaderfield.delegate = self;
    _leaderfield.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 40);
 
          [cell.contentView addSubview:_leaderfield];

}
    if(_dic&&![_leader isEqual:[NSNull null]]){

 _leaderfield.text =_leader;


 }
return cell;
}else if (indexPath.row ==4){
 static NSString *cellid04 = @"cellid04";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid04];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid04];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"参会人数";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _meetingnumfield = [[zhucetextfield alloc]init];
              _meetingnumfield.delegate = self;
    _meetingnumfield.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 40);
 
          [cell.contentView addSubview:_meetingnumfield];

}
   if(_dic&&![_num isEqual:[NSNull null]]){

 _meetingnumfield.text =_num;


 }
return cell;
}else if (indexPath.row ==5){
 static NSString *cellid05 = @"cellid05";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid05];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid05];
    
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"联系电话";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _phonefield = [[zhucetextfield alloc]init];
              _phonefield.delegate = self;
    _phonefield.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 40);
 
          [cell.contentView addSubview:_phonefield];

}
   if(_dic&&![_phone isEqual:[NSNull null]]){

 _phonefield.text =_phone;


 }
return cell;
}


else if (indexPath.row ==6){
 static NSString *cellid06 = @"cellid06";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid06];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid06];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"地点";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _placebutton = [zhucebutton buttonWithType:UIButtonTypeCustom];
      _placebutton.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 40);
[_placebutton addTarget:self action:@selector(placeaction) forControlEvents:UIControlEventTouchUpInside];
   [cell.contentView addSubview:_placebutton];
            [_placebutton setTitle:@"选择地点" forState:UIControlStateNormal];

}
  if(_placestring.length>0){
         [_placebutton setTitle:_placestring forState:UIControlStateNormal];
         }
          if(_dic&&![_placestring isEqual:[NSNull null]]){

            [_placebutton setTitle:_placestring forState:UIControlStateNormal];


 }
return cell;
}else if (indexPath.row ==7){
 static NSString *cellid07 = @"cellid07";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellid07];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid07];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0,KScreenWidth-20, 20)];
  label.textColor = [UIColor colorWithHexString:@"484848"];
label.text = @"备注";
//label.attributedText = attrStr;
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _marktview = [[zhucetextview alloc]init];
              _marktview.delegate = self;
    _marktview.frame = CGRectMake(10, label.bottom, (KScreenWidth-20), 80);
 
          [cell.contentView addSubview:_marktview];

}
  if(_dic&&![_mark isEqual:[NSNull null]]){

 _marktview.text =_mark;


 }
return cell;
}else{
     static NSString *CellIdentifier2 = @"Cellbendititlepic2";

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

//        cell.backgroundColor = [UIColor colorWithHexString:@"f0eff5"];
    }
     UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
      button.frame = CGRectMake(20, 10, (KScreenWidth-60)/2, 40);
button.backgroundColor = [UIColor colorWithHexString:@"0a62ea"];

    [button setTitle:@"同意" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize: 15.0];
    [button setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
        button.layer.cornerRadius = button.height/2;
        [button addTarget:self action:@selector(tyaction) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button];

     UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
      button2.frame = CGRectMake(button.right+ 20, 10, (KScreenWidth-60)/2, 40);
button2.backgroundColor = [UIColor colorWithHexString:@"0a62ea"];

    [button2 setTitle:@"不同意" forState:UIControlStateNormal];
    button2.titleLabel.font = [UIFont systemFontOfSize: 15.0];
    [button2 setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
        button2.layer.cornerRadius = button.height/2;
        [button2 addTarget:self action:@selector(btyaction) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button2];
    return cell;
    
  
    }
    }
- (void)textFieldDidEndEditing:(UITextField *)textField{
if (textField ==_huiyifield) {
    _name = _huiyifield.text;
}if (textField ==_bumenfield) {
    _bumen = _bumenfield.text;
}if (textField ==_leaderfield) {
    _leader = _leaderfield.text;
}if (textField ==_meetingnumfield) {
    _num = _meetingnumfield.text;
}if (textField ==_phonefield) {
    _phone = _phonefield.text;
}
}
- (void)textViewDidEndEditing:(UITextView *)textView{
if (textView ==_marktview) {
    _mark = _marktview.text;
}
}
- (void)placeaction{
if (_array.count>0) {
        [self.view endEditing:YES];
    [self.lzPickerVIew lzPickerVIewType:LZPickerViewTypeSexAndHeight];
self.lzPickerVIew.dataSource =_array;
 [self.lzPickerVIew show];
    __weak typeof(self) weakSelf = self;
 self.lzPickerVIew.selectValue  = ^(NSString *value){

        [weakSelf.placebutton setTitle:value forState:UIControlStateNormal];
      weakSelf.placestring = value;
     
    };
}

}

- (void)startaction{
        [self.view endEditing:YES];
            _startdatePicker = [[LYSDatePickerController alloc] init];
            _startdatePicker.headerView.backgroundColor = [UIColor colorWithRed:84/255.0 green:150/255.0 blue:242/255.0 alpha:1];
            _startdatePicker.indicatorHeight = 5;
            _startdatePicker.delegate = self;
            _startdatePicker.headerView.centerItem.textColor = [UIColor whiteColor];
            _startdatePicker.headerView.leftItem.textColor = [UIColor whiteColor];
            _startdatePicker.headerView.rightItem.textColor = [UIColor whiteColor];
            _startdatePicker.pickHeaderHeight = 40;
            _startdatePicker.pickType = LYSDatePickerTypeTime;
            _startdatePicker.minuteLoop = YES;
            _startdatePicker.headerView.showTimeLabel = NO;
            _startdatePicker.weakDayType = LYSDatePickerWeakDayTypeUSDefault;
            _startdatePicker.showWeakDay = YES;
                __weak typeof(self) weakSelf = self;

            [_startdatePicker setDidSelectDatePicker:^(NSDate *date) {
                NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
                [dateFormat setDateFormat:@"HH:mm"];
                weakSelf.starttime = [dateFormat stringFromDate:date];
      [weakSelf.starttimebutton setTitle:weakSelf.starttime forState:UIControlStateNormal];
            }];
            [_startdatePicker showDatePickerWithController:self];
        }
- (void)endaction{
        [self.view endEditing:YES];
            _enddatePicker = [[LYSDatePickerController alloc] init];
            _enddatePicker.headerView.backgroundColor = [UIColor colorWithRed:84/255.0 green:150/255.0 blue:242/255.0 alpha:1];
            _enddatePicker.indicatorHeight = 5;
            _enddatePicker.delegate = self;
            _enddatePicker.headerView.centerItem.textColor = [UIColor whiteColor];
            _enddatePicker.headerView.leftItem.textColor = [UIColor whiteColor];
            _enddatePicker.headerView.rightItem.textColor = [UIColor whiteColor];
            _enddatePicker.pickHeaderHeight = 40;
            _enddatePicker.pickType = LYSDatePickerTypeTime;
            _enddatePicker.minuteLoop = YES;
            _enddatePicker.headerView.showTimeLabel = NO;
            _enddatePicker.weakDayType = LYSDatePickerWeakDayTypeUSDefault;
            _enddatePicker.showWeakDay = YES;
                __weak typeof(self) weakSelf = self;

            [_enddatePicker setDidSelectDatePicker:^(NSDate *date) {
                NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
                [dateFormat setDateFormat:@"HH:mm"];
                weakSelf.endtime = [dateFormat stringFromDate:date];
      [weakSelf.endtimebutton setTitle:weakSelf.endtime forState:UIControlStateNormal];
            }];
            [_enddatePicker showDatePickerWithController:self];
        }
- (void)timeaction{
_setupPicker = [[MHDatePicker alloc] init];
    _setupPicker.isBeforeTime = YES;
    _setupPicker.datePickerMode = UIDatePickerModeDate;
    
    __weak typeof(self) weakSelf = self;
    [_setupPicker didFinishSelectedDate:^(NSDate *selectedDate) {
//        NSString *string = [NSString stringWithFormat:@"%@",[NSDate dateWithTimeInterval:3600*8 sinceDate:selectedDate]];
//        weakSelf.myLabel2.text = string;
      NSString *string = [weakSelf dateStringWithDate:selectedDate DateFormat:@"yyyy-MM-dd"];
      _time = string;
      [weakSelf.timebutton setTitle:string forState:UIControlStateNormal];
    }];

}
- (NSString *)dateStringWithDate:(NSDate *)date DateFormat:(NSString *)dateFormat
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:dateFormat];
    [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"]];
    NSString *str = [dateFormatter stringFromDate:date];
    return str ? str : @"";
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
